﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.Hosting;
using System.Web;

namespace charpter_1_2
{
    public class Intelligencer : System.MarshalByRefObject
    {
        public string GetHostingEnvironmentInfo()
        {
            System.AppDomain appdomain = System.AppDomain.CurrentDomain;
            StringBuilder builder = new StringBuilder();

            // 应用程序域的信息
            builder.AppendFormat("Domain ID: {0}\r\n", appdomain.Id);

            // 对于每一个 Web 应用程序域，有一个 HostingEnvironment
            builder.AppendFormat("VirtualPath: {0}\r\n", HostingEnvironment.ApplicationVirtualPath);
            builder.AppendFormat("PhysicalPath: {0}\r\n", HostingEnvironment.ApplicationPhysicalPath);

            return builder.ToString();
        }

        public string GetHttpRuntimeInfo()
        {
            StringBuilder builder = new StringBuilder();

            // 每个 Web 应用程序域中，有一个 HttpRuntime
            builder.AppendFormat("AppDomainAppId: {0}\r\n",
                    HttpRuntime.AppDomainAppId);
            builder.AppendFormat("AppDomainAppPath: {0}\r\n",
                    HttpRuntime.AppDomainAppPath);
            builder.AppendFormat("AppDomainAppVirtualPath: {0}\r\n",
                    HttpRuntime.AppDomainAppVirtualPath);
            builder.AppendFormat("AspClientScriptVirtualPath: {0}\r\n",
                    HttpRuntime.AspClientScriptVirtualPath);
            builder.AppendFormat("AspClientScriptPhysicalPath: {0}\r\n",
                    HttpRuntime.AspClientScriptPhysicalPath);
            builder.AppendFormat("AppDomainId: {0}\r\n",
                    HttpRuntime.AppDomainId);
            builder.AppendFormat("AspInstallDirectory: {0}\r\n",
                    HttpRuntime.AspInstallDirectory);
            builder.AppendFormat("BinDirectory: {0}\r\n",
                    HttpRuntime.BinDirectory);
            builder.AppendFormat("ClrInstallDirectory: {0}\r\n",
                    HttpRuntime.ClrInstallDirectory);
            builder.AppendFormat("CodegenDir: {0}\r\n",
                    HttpRuntime.CodegenDir);
            builder.AppendFormat("IsOnUNCShare: {0}\r\n",
                    HttpRuntime.IsOnUNCShare.ToString());
            builder.AppendFormat("MachineConfigurationDirectory: {0}\r\n",
                    HttpRuntime.MachineConfigurationDirectory);
            builder.AppendFormat("UsingIntegratedPipeline: {0}\r\n",
                    HttpRuntime.UsingIntegratedPipeline);
            return builder.ToString();
        }
    }
}
